<?php
!function_exists('readover') && exit('Forbidden');

if(file_exists(D_P."data/bbscache/hits.txt")){
	if($hitsize < 5120){
		$hitarray = explode("\t",readover(D_P."data/bbscache/hits.txt"));
		$hits	= array_count_values($hitarray);
		$count	= 0;
		$hits_a	=array();
		foreach($hits as $key=>$value){
			if(is_numeric($key)){
				$value = $value > 4 ? round($value/10)*10+1 : 3;
				$hits_a[$value][] = $key;
			}
		}
		foreach($hits_a as $key=>$val){
			$db->update("UPDATE pw_threads SET hits=hits+".pwEscape($key,false)."WHERE tid IN(".pwImplode($val,false).")");
			if(++$count>300) break;
		}
		$nowtime	= ($timestamp-$tdtime)/3600;
		$hit_control= floor($nowtime/$db_hithour)+1;
		if($hit_control>24/$db_hithour) $hit_control = 1;
		$db->update("UPDATE pw_bbsinfo SET hit_control=".pwEscape($hit_control,false).",hit_tdtime=".pwEscape($tdtime,false)."WHERE id=1");
		unset($hitarray,$hits);
	}
	P_unlink(D_P."data/bbscache/hits.txt");
}
?>